﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using IntroduceCompany.Singleton;

namespace IntroduceCompany.Controllers
{
    [HandleError]
    public class BaseController : Controller
    {
        protected override void OnException(ExceptionContext filterContext)
        {
            if (filterContext.Exception is UnauthorizedAccessException)
            {
                String ss = filterContext.Exception.Message;
                filterContext.Result = new RedirectResult("/vi/Error/NotAuthorized");
                filterContext.ExceptionHandled = true;
            }
            base.OnException(filterContext);
        }

        //protected override void OnAuthorization(AuthorizationContext filterContext)
        //{
        //    //   bool boo = HttpContext.Current.User.IsInRole("asd");
        //    if (HttpContext.User.Identity.Name != "" && DataSingleton.GetInstance().Administrators.SingleOrDefault(u => u.UserName == HttpContext.User.Identity.Name).Visible)
        //    {
        //        return;
        //    }

        //    Redirect("/Views/Backend/Error/NotAuthorized.aspx");
        //}

    }
}
